From: Florian Müllner Date: Sun, 22 Jul 2018 01:31:54 +0000 (+0200) Subject: windowManager: Move animation into WindowDimmer X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~839^2^2~51 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=fc958f4215255b4e396fca8bd2777a5ca4ffa173;p=gnome-shell.git windowManager: Move animation into WindowDimmer Currently WindowDimmer exposes a JS property that is used to control the underlying effect. This works fine with Tweener, but not with Clutter animations which we want to use ultimately. As a first step towards that, expose a setDimmed() method instead of the property and handle the animation internally, so it can be adapted more easily. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/666 --- diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js index d932c22fb..f7e4dc211 100644 --- a/js/ui/windowManager.js +++ b/js/ui/windowManager.js @@ -135,14 +135,25 @@ var WindowDimmer = class { this._syncEnabled(); } - set dimFactor(factor) { - this._dimFactor = factor; - this._brightnessEffect.set_brightness(factor * DIM_BRIGHTNESS); - this._syncEnabled(); - } - - get dimFactor() { - return this._dimFactor; + setDimmed(dimmed, animate) { + let factor = dimmed ? 1.0 : 0.0; + + if (animate) { + Tweener.addTween(this, { + _dimFactor: factor, + time: (dimmed ? DIM_TIME : UNDIM_TIME) / 1000, + transition: 'linear', + onUpdate: () => { + let brightness = this._dimFactor * DIM_BRIGHTNESS; + this._brightnessEffect.set_brightness(brightness); + this._syncEnabled(); + } + }); + } else { + this._dimFactor = factor; + this._brightnessEffect.set_brightness(factor * DIM_BRIGHTNESS); + this._syncEnabled(); + } } }; @@ -1582,14 +1593,7 @@ var WindowManager = class { let dimmer = getWindowDimmer(actor); if (!dimmer) return; - if (this._shouldAnimate()) - Tweener.addTween(dimmer, - { dimFactor: 1.0, - time: DIM_TIME / 1000, - transition: 'linear' - }); - else - dimmer.dimFactor = 1.0; + dimmer.setDimmed(true, this._shouldAnimate()); } _undimWindow(window) { @@ -1599,13 +1603,7 @@ var WindowManager = class { let dimmer = getWindowDimmer(actor); if (!dimmer) return; - if (this._shouldAnimate()) - Tweener.addTween(dimmer, - { dimFactor: 0.0, - time: UNDIM_TIME / 1000, - transition: 'linear' }); - else - dimmer.dimFactor = 0.0; + dimmer.setDimmed(false, this._shouldAnimate()); } _mapWindow(shellwm, actor) {